package com.woniuxy.searchassembly.controller;


import com.woniuxy.common.Result;
import com.woniuxy.hotel.api.SightPointAPI;
import com.woniuxy.hotel.form.SightForm;
import com.woniuxy.searchassembly.model.SightPoint;
import com.woniuxy.searchassembly.service.ISightPointService;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Kevin Kwok
 * @since 2021-05-24
 */
@Slf4j
@RestController
public class SightPointController implements SightPointAPI {
    @Resource
    private ISightPointService sightPointService;

    @Override
    public Result queryArea(String area) {
        List<String> strings = sightPointService.queryArea(area);
        return new Result(true,"查询成功",strings);
    }

    @Override
    public Result queryBySight(String name) {
        SightPoint sightPoint = sightPointService.querySightInfo(name);
        return new Result(true,"查询成功",sightPoint);
    }

    @Override
    public Result addNewSight(SightForm sightForm) {
        SightPoint sightPoint = new SightPoint();
        BeanUtils.copyProperties(sightForm,sightPoint);
        int i = sightPointService.addNewSights(sightPoint);
        return new Result(true,"景区新增成功",i);
    }
}

